package cn.edu.zju.om.crawler;

import java.util.Date;

import com.sleepycat.persist.model.Entity;
import com.sleepycat.persist.model.PrimaryKey;

@Entity
public class Task {
	
	@PrimaryKey
	private String url;
	
	private Date finishTime;
	
	private boolean isFailed;
	
	public Task(String url) {
		this.url = url;
		this.finishTime = null;
		this.isFailed = false;
	}
	
	private Task() {
	}
	
	public String getUrl() {
		return this.url;
	}
	
	public void done() {
		finishTime = new Date();
	}
	
	public boolean isDone() {
		return finishTime != null;
	}
	
	public void fail() {
		isFailed = true;
	}
	
	public boolean isFailed() {
		return isFailed;
	}
	
	public Date getFinishTime() {
		return this.finishTime;
	}
	
	

}
